home *** CD-ROM | disk | FTP | other *** search
- ; HSD.LSP [Article Figure 1] (c)1990, Barry Bowen
-
- ; ****************************** HSD.LSP **********************
- ; Copyright (c) Barry R. Bowen 1990
- ; -------------------------------------------------------------
- ; TOOLBOX ROUTINES USED:
- ; (E1),(E2),(E3) Routines for entity handling (Sept '89)
- ; *ERROR* Error handling routine (Sept '89)
- ; (LS),(RL) Routines for automatic layering (Feb '90)
- ; (S2),(S4) Routines for selection-sets (Sept '89)
- ; (V1),(V1R) System variable routines (Feb '89)
- ; (V3),(V4) Start-up and ending routines (Feb '89)
- ; -------------------------------------------------------------
- ; Variables:
- ; ANS = Variable for questions
- ; CK = Used in ADDL to get selection-set
- ; FILE = File to open/write/read
- ; EN = Entity name
- ; IN = Counter
- ; INT = Intersection of PT1, PT2 & line selected line
- ; LAYR = Layer for lines to be dimensioned
- ; LINE = One line in the file DIM and DIM1
- ; PT1 - PT5 = User selected points
- ; SS1 = Selection set crossing PT1 & PT2
- ; SS2 = Additional line and point selection-sets
- ; STL = String length for MKPT
- ; TEMP = Temporary variable
- ; X = X point coordinate
- ; Y = Y point coordinate
- ;--------------------------------------------------------------
- (defun C:HSD (/ ANS CK FILE EN INT IN LAYR LINE PT1 PT2 ; 1
- PT3 PT4 PT5 SS1 SS2 STL TEMP X Y) ; 2
- (V3) ; 3
- (V1 '("dimse1" "dimse2" "flatland" "orthomode" "snapmode" ; 4
- "osmode")) ; 5
- (setvar "osmode" 0) ; 6
- (foreach N '("flatland" "orthomode" "dimse1" "dimse2") ; 7
- (setvar N 1)) ; 8
- (setq IN 0 ; 9
- FILE (open "DIM" "w") ;10
- PT1 (getpoint "\nDimension Line First Point: ") ;11
- PT2 (getpoint PT1 "\nDimension Line Second Point:")) ;12
- (E1 "Select Line for Layer Check: ") ;13
- (while (not EN) ;14
- (prompt "\nNo Line Selected-Try Again") ;15
- (E1 "Select Line: ") ;16
- ) ;End While line 14 ;17
- (E2) ;18
- (E3 'LAYR 8) ;Get layer ;19
- (setq SS1 (ssget "c" PT1 PT2)) ;20
- (S4 "LINE") ;Makes sure all entities are lines first ;21
- (S4A SS1) ;Check Layers ;22
- (AUTO SS1) ;Write points to file ;23
- (ANSR "\nSelect Lines Not Crossing Intersection? <Y>: ") ;24
- (if (/= ANS "N") (ADDL)) ;25
- (ANSR "\nSelect Lines Not On Selected Layer? <Y>: ") ;26
- (if (/= ANS "N") ;27
- (progn (setq CK T) (ADDL) (setq CK nil))) ;28
- (ANSR "\nAdd Additional Point Selections? <Y>: ") ;29
- (if (/= ANS "N") ;30
- (progn ;31
- (setvar "blipmode" 1) ;32
- (setq TEMP (getpoint "\nSelect Point: ")) ;33
- (while TEMP ;34
- (setq X (rtos (+ (car TEMP) 5000) 2 2) ;35
- Y (rtos (cadr TEMP) 2 2) ;36
- LINE (strcat X "," Y "*") ;37
- TEMP (getpoint "\nSelect Point: ")) ;38
- (write-line LINE FILE) ;39
- ) ;End While line 34 ;40
- (setvar "blipmode" 0) ;41
- ) ;End Progn line 31 ;42
- ) ;End If line 30 ;43
- (close FILE) ;44
- (command "type" "dim|sort>dim1") ;45
- (setq FILE (open "DIM1" "r")) ;46
- (CKPT) ;Get first point ;47
- (LS "DIM" 5 "") ;Layer/Color/Linetype ;48
- (command "dim" "horiz" PT5) ;First point ;49
- (CKPT) ;Get next point ;50
- (command PT5 PT1 "") ;Second point ;51
- (EXTRA) ;Change color of text ;52
- (CKPT) ;Get next point ;53
- (setvar "dimse1" 1) ;First Extension line off ;54
- (while (/= LINE nil) ;Continue diminsioning ;55
- (command "continue" PT5 "");Dimension next point ;56
- (EXTRA) ;Change color of text ;57
- (CKPT) ;Get next point ;58
- ) ;End While line ;59
- (command "exit") ;Exit the DIM command ;60
- (close FILE) ;Close and end ;61
- (RL) ;Restore previous layer ;62
- (V1R) ;Restore system variables ;63
- (V4) ;Reset environment ;64
- ) ;65
-
- ; ----------------------- CKPT --------------------------------
- (defun CKPT (/ STL)
- (setvar "dimse2" 1) ;Second Extendion line off
- (setq LINE (read-line FILE));Read point from file
- (if LINE
- (progn
- (setq STL (strlen LINE))
- (if (= (substr LINE STL 1) "*")
- (progn
- (setq LINE (substr LINE 1 (1- STL)))
- (MKPT LINE)
- (setvar "dimse2" 0)
- ))
- ))
- (if LINE (MKPT LINE))
- )
-
- ; ----------------------- AUTO --------------------------------
- (defun AUTO (SST)
- (setq IN 0 EN (ssname SST IN))
- (while EN
- (setq INT nil)
- (E2)
- (E3 'PT3 10)
- (E3 'PT4 11)
- (setq INT (inters PT1 PT2 PT3 PT4))
- (if (not INT)
- (progn
- (setq INT1 (inters PT1 PT2 PT3 PT4 nil))
- (if (> (distance INT1 PT3) (distance INT1 PT4))
- (progn
- (setq X (rtos (+ (car PT4) 5000) 2 2)
- Y (rtos (cadr PT4) 2 2)))
- (progn
- (setq X (rtos (+ (car PT3) 5000) 2 2)
- Y (rtos (cadr PT3) 2 2)))
- )
- (setq LINE (strcat X "," Y "*"))
- )
- (progn
- (setq X (rtos (+ (car INT) 5000) 2 2)
- Y (rtos (cadr INT) 2 2)
- LINE (strcat X "," Y))
- ))
- (setq IN (1+ IN)
- EN (ssname SST IN))
- (write-line LINE FILE)
- )
- )
-
- ; ----------------------- ADDL --------------------------------
- (defun ADDL (/ SS2)
- (prompt "\nSelect Additional Lines: ")
- (setq SS2 (ssget))
- (S4 "LINE")
- (if (/= CK T) (S4A SS2))
- (AUTO SS2)
- )
-
- ; ------------------------ S4A --------------------------------
- (defun S4A (SSS / IN ELIST)
- (setq IN 0)
- (while (S2 'EN SSS)
- (E2)
- (if (= (E3 'ET 8) LAYR)
- (setq IN (1+ IN))
- (ssdel EN SSS))
- )
- )
-
- ; ----------------------- EXTRA -------------------------------
- (defun EXTRA ()
- (if (= (getvar "dimaso") 0)
- (progn
- (command "exit"
- "change" (entlast) "" "p" "c" "7" ""
- "dim")
- ) )
- )
-
- ; ----------------------- MKPT --------------------------------
- (defun MKPT (A)
- (setq X "")
- (while (and (/= "" A) (/= "," (substr A 1 1)))
- (setq X (strcat X (substr A 1 1))
- A (substr A 2 (strlen A)))
- )
- (setq Y (read (substr A 2 (- (strlen X) 1)))
- X (- (read X) 5000)
- PT5 (list X Y))
- )
-
- ; ----------------------- ANSR --------------------------------
- (defun ANSR (PRMT)
- (initget "Y N")
- (setq ANS (getkword PRMT))
- )
-